package cn.edu.zzuli.nothinglink.mapper.provider;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.jdbc.SQL;

import java.util.List;

public class WorkSubmitRecordProvider {

    public String getWorkIdsByInfo(@Param("workIds") List<Integer> workIds, @Param("stuId")  Integer stuId) {

        StringBuilder sb = new StringBuilder();
        sb.append("( ");

        SQL sql = new SQL();
        for (int i = 0; i < workIds.size(); i++) {
            if (i != workIds.size() - 1) {
                sb.append(workIds.get(i) + ", ");
            }else {
                sb.append(workIds.get(i) + " )");
            }
        }

        String workIdsString = sb.toString();
        sql.SELECT("work_id").FROM("work_submit_record")
                .WHERE("work_id in" + workIdsString)
                .WHERE("ws_stu_id = #{stuId}");

        return sql.toString();
    }

}
